class_name Skill_GenerateRound
extends Resource

@export var repeat_times_range:Vector2i = Vector2i.ONE
@export var interval_range:Vector2
@export var local_space:bool = true
@export var reset_pre_times:bool = true
@export var is_add_angle:bool = true
@export var is_add_pos:bool = true
@export var items:Array[Skill_GenerateItem]
var angle:float = 0
var pos:Vector2 = Vector2.ZERO
var cur_item:SkillAction
var scenes:Array[PackedScene] = []

func init(item:SkillAction,scenes:Array[PackedScene]):
	cur_item = item
	self.scenes = scenes
	reset()
func reset():
	angle = cur_item.skill.global_rotation_degrees if local_space else 0
	pos = cur_item.skill.global_position if local_space else Vector2.ZERO
func set_angle(angle:float):
	if is_add_angle:
		self.angle += angle
	else:
		self.angle = angle
func set_pos(offest:Vector2):
	if is_add_pos:
		self.pos += offest
	else:
		self.pos = offest
func create_tween():
	if not scenes or scenes.size() == 0:
		return null
	var tween:Tween = cur_item.create_tween()
	for i in range(items.size()):
		items[i].create_tween(self,tween)
		if i < items.size() - 1:
			var interval = randf_range(interval_range.x,interval_range.y)
			tween.tween_interval(interval)
	return tween
